]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
runDialog: Require matching key-press for ESC shortcut
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 3 Jan 2025 23:17:53 +0000 (00:17 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 10 Jan 2025 11:46:14 +0000 (12:46 +0100)
Both popover menus and dialogs can be dismissed with the Escape key,
however the former triggers on key press, while the latter triggers
on key release. As a result, the same key press+release can dismiss
both the command entry's context menu and the run dialog itself.

Fix this by only triggering a key shortcut when a matching key press
was recorded before, which matches how Dialog handles button shortcuts.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8132
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3585>
(cherry picked from commit 9b9191e8585025eb038d08fa63227f46a4b22cb8)

js/ui/runDialog.js

index 970dedd67afc522ed0b0661207c6a07e29bcc5eb..7e32d74bb12fa95573d9ea7e53055c9351f38dc9 100644 (file)
@@ -82,6 +82,7 @@ class RunDialog extends ModalDialog.ModalDialog {
         content.add_child(this._descriptionLabel);
 
         this._commandError = false;
+        this._pressedKey = null;
 
         this._pathCompleter = new Gio.FilenameCompleter();
 
@@ -120,8 +121,19 @@ class RunDialog extends ModalDialog.ModalDialog {
         });
     }
 
+    vfunc_key_press_event(event) {
+        this._pressedKey = event.get_key_symbol();
+    }
+
     vfunc_key_release_event(event) {
-        if (event.get_key_symbol() === Clutter.KEY_Escape) {
+        const pressedKey = this._pressedKey;
+        this._pressedKey = null;
+
+        const key = event.get_key_symbol();
+        if (key !== pressedKey)
+            return Clutter.EVENT_PROPAGATE;
+
+        if (key === Clutter.KEY_Escape) {
             this.close();
             return Clutter.EVENT_STOP;
         }